﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using ZLDC.Common.Estate;
namespace ZLDC.Estate.Quantify.Package
{
    public partial class lp_PackageSet : System.Web.UI.Page
    {
        protected string depttype;
        protected void Page_Load(object sender, EventArgs e)
        {
            depttype = ZLDC.Topo.BLL.Estate.lp_Report_list.GetType(_Utility.GetInfoBySession().m_sDeptID);//获取部门类型
            if (!IsPostBack)
            {
                GetPackageList(depttype);
            }
        }

        /// <summary>
        /// 查询上级默认套餐
        /// </summary>
        protected void GetPackageList(string depttype)
        {
           
            DataSet ds=ZLDC.Topo.BLL.Estate.lp_PackageSet.GetPckList(ZLDC.Topo.BLL.Estate.lp_Basis.GetDeptList(_Utility.GetInfoBySession().m_sDeptID));
            RpList.DataSource = ds;
            RpList.DataBind();
            txtTotal2.Value = ZLDC.Topo.BLL.Estate.lp_Basis.Exists_Set();//获取最低分数
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        //Eval("CompleteNum"数量),Eval("Point"分值),Eval("Score"最高分)Quantity
        protected int GetHeiht(object CompleteNum, object Point, object Score, object Quantity, object Choose)
        {
            if (Choose.ToString() == "1")
            {
                if (int.Parse(Score.ToString()) == 0)
                {
                    decimal total = (Convert.ToDecimal(Point.ToString()) / Convert.ToDecimal(CompleteNum.ToString()) * Convert.ToDecimal(Quantity.ToString()));
                    int fk = int.Parse(Math.Round(total).ToString());
                    return fk;
                }
                else
                {
                    decimal total = (Convert.ToDecimal(Point.ToString()) / Convert.ToDecimal(CompleteNum.ToString()) * Convert.ToDecimal(Quantity.ToString()));
                    int fk = int.Parse(Math.Round(total).ToString());
                    if (total > int.Parse(Score.ToString()))
                    {
                        return int.Parse(Score.ToString());

                    }
                    else
                    {
                        return fk;
                    }
                }
            }
            else
            {
                return 0;
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            ZLDC.Topo.BLL.Estate.lp_PackageSet.BtnUpdate( RpList, Page,txtName,depttype, hiduserid);
        }
    }
}
